define(['angular'], function (angular) {

/*-----------------------------------------
 *   demo serice
 ------------------------------------------*/
angular.module('books.service.count', [])
    .constant('countServiceConfig', {
        files:{//调用json数据
            retrCountList:'app/data/demo/countJson.json'
        },
        urls:{
            retrCountList:'http://47.92.95.246:8012/listCount'//调用后台api接口
        }
    })
    .factory('countService',['$http', '$q', 'countServiceConfig', function ($http, $q, countServiceConfig) {
        return {
            /**
             * 查询统计页信息列表
             * @return {[type]} [description]
             */
            retrCountList: function(){
                //内置服务 同步请求数据
                var deffered = $q.defer();
                //请求数据
                $http({
                    method:'GET',
                    dataType: "json",
                    contentType:'application/json; charset=UTF-8',
                    // url:countServiceConfig.urls.retrCountList
                    url:countServiceConfig.urls.retrCountList
                })
                .success(function(response){
                    deffered.resolve(response);
                })
                .error(function(e, code){
                    deffered.reject(code);
                });
                return deffered.promise; 
            }
            
        };
    }]);

});
